using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

using phorm.database.core;

namespace phorm.model.fields
{
    /// <summary>
    /// A primary key for this column's model object.
    /// </summary>
    public class PrimaryKey : Integer
    {
        /// <summary>
        /// Set to true if this column is set to automatically increment.
        /// </summary>
        public Boolean auto_increment = true;

        /// <summary>
        /// Constructor assumes integer field type with length 11.
        /// </summary>
        /// <param name="obj">The model object to which this column belongs</param>
        public PrimaryKey(DatabaseRecord obj)
            : base(obj)
        {
            this._model.primary_key = this;
        }

        /// <summary>
        /// Constructor assumes integer field type.
        /// </summary>
        /// <param name="obj">The model object to which this column belongs</param>
        /// <param name="len">The length of this column</param>
        public PrimaryKey(DatabaseRecord obj, int len)
            : base(obj, len)
        {
            this._model.primary_key = this;
        }

        /// <summary>
        /// Constructor that requires length, field type and whether or not to set auto_increment.
        /// </summary>
        /// <param name="obj">The model object to which this column belongs</param>
        /// <param name="len">The length of this column</param>
        /// <param name="field_type">The field type of this column</param>
        /// <param name="auto_increment">True if the column should automatically increment</param>
        public PrimaryKey(DatabaseRecord obj, int len, String field_type, Boolean auto_increment)
            : base(obj, len)
        {
            this.field_type = field_type;
            this.auto_increment = auto_increment;
            this._model.primary_key = this;
        }
    }
}
